<?php
/**
 * Here is your custom functions.
 */

use think\cache\driver\Redis;

define('CURRENT_MP', 'current_mp');
define('CURRENT_MINI', 'current_mini');
define('CURRENT_WECHAT', 'current_wechat');

define('SESSION_MP_FOLLOW', 'mpFollowInfo');
define('WECHAT_WAP_MP', 'wechat_wap_mp');  //wap模块的mp会话
define('WECHAT_WAP_TENANTID', 'wechat_wap_tid');  //wap模块的mp会话

if(! function_exists('wechat_redis')){
    /**
     *
     * @return object
     * Author: fudaoji<fdj@kuryun.cn>
     */
    function wechat_redis(){
        return (new Redis(config('thinkcache.stores.redis')))->handler();
    }
}

if(! function_exists('wechat_publish_time')){
    /**
     * 时间友好显示
     * @param $time
     * @param string $format
     * @return string
     * Author: fudaoji<fdj@kuryun.cn>
     */
    function wechat_publish_time($time, $format = ''){
        return publish_time($time, $format);
    }
}

if(! function_exists('wechat_cache_key')){
    /**
     * 生成缓存key
     * @param string $key
     * @return string
     * Author: fudaoji<fdj@kuryun.cn>
     */
    function wechat_cache_key($key = ''){
        return md5('wechat:' . $key);
    }
}